enum StateType {
    GENERAL,
    END
}

class State {

    protected static _idCnt: number = 0

    protected _id: number

    protected _stateType: StateType

    public next: Map<string, Set<State>> = new Map()

    constructor() {
        this._id = State._idCnt++
        this._stateType = StateType.GENERAL
    }

    public addNext(edge: string, state: State) {
        let set = this.next.get(edge)
        if(!set) {
            set = new Set()
            this.next.set(edge, set)
        }
        set.add(state)
    }

    public set stateType(stateType: StateType) {
        this._stateType = stateType
    }

    public get isEndState(): boolean {
        return this._stateType === StateType.END
    }

    public get id(): number {
        return this._id
    }

    public static get idCnt(): number {
        return State._idCnt
    }

    public static reset() {
        State._idCnt = 0
    }

}

export default State

export { State, StateType }